<template>
    <div class="home flex-row">欢迎来到首页</div>
</template>
<script setup>
defineOptions({ name: 'Home' })
import { ElMessage } from 'element-plus'
import { ref } from 'vue'
import * as echarts from 'echarts'
import { onMounted, onUnmounted } from 'vue'
import { getLoginUser } from '@/api/common'
// 引入全局化储存
import { user } from '../../../store/user'
const userKey = user()

// 窗口大小变化时，重置图表大小
const handleResize = () => {
    setTimeout(() => {
        if (myChart) {
            myChart.resize()
        }
    }, 100)
}
const init = async () => {
    const ken = await getLoginUser({})
    if (ken.code === 200) {
        userKey.setUserInfo(ken.data)
    }
}
onMounted(() => {
    init()
    // setChartOptions()
    window.addEventListener('resize', handleResize)
})
onUnmounted(() => {
    // 在卸载组件之后调用
    // myChart.dispose()
    window.removeEventListener('resize', handleResize)
})
</script>
